package com.briup.web;/*
 * @Description:
 * @Author: 枸男人
 * @Date: 2024/12/04/10:34
 * @LastEditors: 34866
 * @: 你说哥帅,哥笑了,因为哥笑起来更帅
 */

import org.springframework.web.bind.annotation.*;
import com.briup.pojo.Book;
import com.briup.utils.Result;
import com.briup.utils.ResultCode;

@RestController
@RequestMapping("/book")
public class BookController {
    //映射配置
    //127.0.0.1:8081/getById/1
    @RequestMapping(value = "getById/{id}", method = RequestMethod.GET)
    public Book getById(@PathVariable Integer id) {
        System.out.println("getById"+id);
        Book book = new Book();
        book.setId(id);
        book.setName("Java讲义");
        return book;
    }
    @GetMapping(value = "getById1/{id}")
    public Result getById1(@PathVariable Integer id) {
        System.out.println("getById"+id);
        Book book = new Book();
        book.setId(id);
        book.setName("Java讲义");
        int n= id / 0;
        //return book;
        //return Result.success(book);
        if(id==1){
            return Result.failure(ResultCode.DATA_NONE);
        }
        return Result.failure(201,"删除失败");
    }
    @DeleteMapping(value = "delById/{id}")
    public Result delById(@PathVariable Integer id) {
        System.out.println("delById"+id);
        //return "book" + id + "删除成功";
        return Result.success();
    }
}
